package com.xuqm.sdhbwfu.app.viewmodel

import com.xuqm.base.di.manager.HttpManager
import com.xuqm.base.extensions.showMessage
import com.xuqm.base.viewmodel.BaseListViewModel
import com.xuqm.base.viewmodel.callback.Response
import com.xuqm.sdhbwfu.app.model.PmTaskModel
import com.xuqm.sdhbwfu.app.repository.Service
import com.xuqm.sdhbwfu.core.extensions.io_main
import com.xuqm.sdhbwfu.core.extensions.subscribeBy

class PmTaskListViewModel : BaseListViewModel<PmTaskModel>() {

    override fun pageSize(): Int = 999999

    override fun loadData(page: Int, onResponse: Response<PmTaskModel>) {

        add(HttpManager.getApi(Service::class.java)
            .pmTaskList()
            .io_main()
            .subscribeBy(
                {
                    onResponse.onResponse(it)
                }, {
                    onResponse.onResponse(null)
                    showMessage(it)
                }
            ))
    }

}